package com.xbai.springcloud.controller;

import com.xbai.springcloud.entity.CommonResult;
import com.xbai.springcloud.service.PaymentFeignService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xbai
 * @Date 2021/5/18
 */
@RestController
@Slf4j
@RequestMapping("/consumer")
@RequiredArgsConstructor
public class OrderFeignController {

    private final PaymentFeignService paymentFeignService;

    @GetMapping("/payment/feign/timeout")
    public String paymentFeignTimeout() {
        // openfeign-ribbon，客户端一般默认等待1s钟
        return paymentFeignService.paymentFeignTimeout();
    }

    @GetMapping("/payment/get/{id}")
    public CommonResult getPayment(@PathVariable("id") Long id) {
        return paymentFeignService.getPaymentById(id);
    }
}
